﻿using System;
using System.Collections.Generic;
using BLL;
using CrystalDecisions.CrystalReports.Engine;
using Model;

public partial class ViewTest_ViewYourself_ViewTTestItem : System.Web.UI.Page
{
    private ReportDocument doc = new ReportDocument();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Page.Unload += new EventHandler(Page_Unload);
    }

    public IList<TTestItemInfo> GetData()
    {
        IList<TTestItemInfo> testItems = new List<TTestItemInfo>();
        TTestItem testItem = new TTestItem();
        string str1 = (string)Session["productSN"];
        DateTime dt1 = (DateTime)Session["testTime"];
        testItems = testItem.GetTestItems(str1, dt1);
        return testItems;
    }

    protected void CrystalReportViewer1_Init(object sender, EventArgs e)
    {
        ForCrystalReport();
    }

    protected void ForCrystalReport()
    {
        doc.Load(Server.MapPath("ViewTestItem.rpt"));
        //doc = new CrystalReport1();

        TextObject txtProductSN = (TextObject)doc.ReportDefinition.ReportObjects["Text4"];
        txtProductSN.Text = "腔体序列号：" + (string)Session["productSN"];
        TextObject txtTestTime = (TextObject)doc.ReportDefinition.ReportObjects["Text13"];
        txtTestTime.Text = "测试时间：" + ((DateTime)Session["testTime"]).ToString();
        TextObject txtProductTypeID = (TextObject)doc.ReportDefinition.ReportObjects["Text14"];
        txtProductTypeID.Text = (string)Session["ProductTypeID"];
        TextObject txtUserID = (TextObject)doc.ReportDefinition.ReportObjects["Text15"];
        txtUserID.Text = (string)Session["UserID"];
        TextObject txtENAID = (TextObject)doc.ReportDefinition.ReportObjects["Text16"];
        txtENAID.Text = (string)Session["ENAID"];
        TextObject txtIsPass = (TextObject)doc.ReportDefinition.ReportObjects["Text17"];
        txtIsPass.Text = (string)Session["IsPass"];

        //TextObject txtTitle = (TextObject)doc.ReportDefinition.ReportObjects["txtTitle"];
        //txtTitle.Text += "相当不错";

        IList<TTestItemInfo> list = GetData();
        doc.SetDataSource(list);
        this.CrystalReportViewer1.ReportSource = doc;
    }

    private void Page_Unload(object sender, EventArgs e)
    {
        doc.Dispose();
    }
}
